package com.lz.atomic;

import java.util.concurrent.atomic.AtomicBoolean;

/**
 * BooleanDemo..
 *
 * 理解expect update
 *
 * @author Lizhong
 * @date 2019/5/14
 */
public class BooleanDemo {
    static AtomicBoolean atomicBoolean=  new AtomicBoolean();
    public static void main(String[] args) {
        boolean flag =true;
        // 如果当前内存值等于期望值，则赋值新值 返回true
        // 内存值!=期望值 返回false
        boolean b = atomicBoolean.compareAndExchange(true, false);
        System.out.println(b);
        System.out.println(flag);
    }
}
